/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 07 - 05
 * Time: 12:29
 */
class Solution4 {
    public int removeElement(int[] nums, int val) {
        int slow = 0;
        int fast = 0;
        while(fast < nums.length) {
            if(nums[fast] != val) {
                nums[slow] = nums[fast];
                fast++;
                slow++;
            }else {
                fast++;
            }
        }
        return slow;
    }
}